package org.fujay.langchain4jserver.domain.model.vo;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 模型连接状态值对象
 */
public record ConnectionStatus(LocalDateTime lastTestTime, TestResult lastTestResult)
        implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    public ConnectionStatus(LocalDateTime lastTestTime, TestResult lastTestResult) {
        this.lastTestTime = lastTestTime;
        this.lastTestResult = lastTestResult != null ? lastTestResult : TestResult.UNTESTED;
    }

    public static ConnectionStatus initial() {
        return new ConnectionStatus(null, TestResult.UNTESTED);
    }

    public ConnectionStatus recordTestResult(TestResult result) {
        return new ConnectionStatus(LocalDateTime.now(), result);
    }
}
